package com.shop2cn.iapi.member.testcase;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.shop2cn.iapi.member.parameter.MchSetCollectionMobileBean;
import com.shop2cn.iapi.member.service.MchSetCollectionMobileCall;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.*;
import com.ymt.utils.tag.*;
import com.ymttest.business.service.shenqi.GodmchManageCallService;
import com.ymttest.database.model.godmember.MchMemberConfig;
import com.ymttest.database.sqlwapper.godmember.GodMemberWapper;
/**
*商家设置是否采集手机号
*FreeMaker Template自动生成代码
*/
@TestSuite
public class Ts_MchSetCollectionMobile{
	private static MchSetCollectionMobileBean mchsetcollectionmobileBean;
	private static MchSetCollectionMobileCall mchsetcollectionmobileCall;
	GodMemberWapper GodMemberWapper;
	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("商家设置是否采集手机号");
	}

	@Before
	public void caseUp() {
		mchsetcollectionmobileBean=new MchSetCollectionMobileBean();
		mchsetcollectionmobileCall=new MchSetCollectionMobileCall();
		GodMemberWapper=new GodMemberWapper();
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(mchsetcollectionmobileCall.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_MchSetCollectionMobile_001() {
		Logger.start(true,"商家设置是否采集手机号成功");
		try {
			Integer shopid= GodmchManageCallService.CreateSellerMch();;
			mchsetcollectionmobileBean.setShopId(shopid);
			mchsetcollectionmobileBean.setCollectionMobile(true);
			mchsetcollectionmobileCall.setData(mchsetcollectionmobileBean);
			mchsetcollectionmobileCall.callService();			
			Logger.verifyEquals("200", mchsetcollectionmobileCall.getString("code"), "验证code");
			Logger.verifyEquals("true", mchsetcollectionmobileCall.getString("data"), "验证data");
			MchMemberConfig db = GodMemberWapper.selectMchMemberConfigByShopId(mchsetcollectionmobileBean.getShopId());
			Logger.verifyEquals(mchsetcollectionmobileBean.getCollectionMobile(), db.getCollectionMobile(), "验证getCollectionMobile");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P2.class})
	@TestCase
	public void Tc_MchSetCollectionMobile_002() {
		Logger.start(true,"不输入shopid失败");
		try {
			mchsetcollectionmobileBean.setCollectionMobile(true);
//			mchsetcollectionmobileBean.setShopId(1);
			mchsetcollectionmobileCall.setData(mchsetcollectionmobileBean);
			mchsetcollectionmobileCall.callService();			
			Logger.verifyEquals("400", mchsetcollectionmobileCall.getString("code"), "验证code");	
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P2.class})
	@TestCase
	public void Tc_MchSetCollectionMobile_003() {
		Logger.start(true,"不输入collectionMobile失败");
		try {
//			mchsetcollectionmobileBean.setCollectionMobile(true);
			mchsetcollectionmobileBean.setShopId(1);
			mchsetcollectionmobileCall.setData(mchsetcollectionmobileBean);
			mchsetcollectionmobileCall.callService();			
			Logger.verifyEquals("400", mchsetcollectionmobileCall.getString("code"), "验证code");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_MchSetCollectionMobile_004() {
		Logger.start(true,"商家数据-修改开关");
		try {
			mchsetcollectionmobileBean.setShopId(1);
			mchsetcollectionmobileBean.setCollectionMobile(true);
			mchsetcollectionmobileCall.setData(mchsetcollectionmobileBean);
			mchsetcollectionmobileCall.callService();			
			Logger.verifyEquals("200", mchsetcollectionmobileCall.getString("code"), "验证code");
			Logger.verifyEquals("true", mchsetcollectionmobileCall.getString("data"), "验证data");
			MchMemberConfig db = GodMemberWapper.selectMchMemberConfigByShopId(mchsetcollectionmobileBean.getShopId());
			Logger.verifyEquals(mchsetcollectionmobileBean.getCollectionMobile(), db.getCollectionMobile(), "验证getCollectionMobile");
			
			mchsetcollectionmobileBean.setCollectionMobile(false);
			mchsetcollectionmobileCall.callService();			
			Logger.verifyEquals("200", mchsetcollectionmobileCall.getString("code"), "验证code");
			Logger.verifyEquals("true", mchsetcollectionmobileCall.getString("data"), "验证data");
			db = GodMemberWapper.selectMchMemberConfigByShopId(mchsetcollectionmobileBean.getShopId());
			Logger.verifyEquals(mchsetcollectionmobileBean.getCollectionMobile(), db.getCollectionMobile(), "验证getCollectionMobile");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
}